#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int n, a[100][100], b[100], c[100];
    scanf("%d", &n);

    for (int i = 0; i < n; i++)  //输入一个含有整数1-n的n个数据序列置于b[]中
        scanf("%d", &b[i]);

    for (int i = 1; i <= n; i++)  //遍历整数1-n
    {
        int index1 = 0, index2, x = 0;
        for (int j = 0; j < n; j++)  //从左往右依次检索数组b[]中元素
        {
            if (b[j] == i)
            {
                index1 = j + 1;  //index1为整数i下标(数组下标+1)
                for (int k = 0; k < n; k++)
                    if (b[k] == index1)
                        index2 = k;  //index2为整数i下标(index1)的数组下标

                for (int k = index2; k < n; k++)  //从b[index2]开始将序列循环(整数i在第x+1行的下标)置于c[]中
                    c[x++] = b[k];

                for (int k = 0; k < index2; k++)
                    c[x++] = b[k];

                for (int k = 0; k < n; k++)  //按照c[]中的序列循环将整数i依次放入每一行相应的位置中
                    a[k][c[k] - 1] = i;  //数组下标=下标-1
            }
        }
    }

    for (int i = 0; i < n; i++)  //输出拉丁方阵
    {
        int count = 0;
        for (int j = 0; j < n; j++)
        {
            if (count != 0)
                printf(" ");
            printf("%d", a[i][j]);
            count++;
        }
        printf("\n");
    }
    return 0;
}